<?php
namespace app\admin\controller\general;

use app\admin\controller\Controller;
use app\admin\model\admin\User as AdminUserModel;
use think\Session;
class Profile extends Controller{
    /**
     * 更新个人后台登录密码
     */
    public function index(){
        $model = AdminUserModel::detail($this->admin['user']['admin_user_id']);
        if ($this->request->isAjax()) {
            if ($model->renew($this->postData('user'))) {
                Session::delete('yoshop_adminuser');
                return $this->renderSuccess('更新成功',url('passport/login'));
            }
            return $this->renderError($model->getError() ?: '更新失败');
        }
        return $this->fetch('index', compact('model'));
    }
}